import Vue from "vue";
import VueRouter from 'vue-router';
import Layout from '@/views/layout/indexLayout.vue'
import Login from '@/views/login/indexLogin.vue'
import Home from '@/views/home/homeContent.vue'

const Product=()=>import('@/views/product/productContent.vue')
const List=()=>import('@/views/product/list/productList.vue')
const Category=()=>import('@/views/product/category/productCategory.vue')

const User=()=>import('@/views/user/userContent.vue')
const UserList=()=>import('@/views/user/list/userList.vue')

const Order=()=>import('@/views/order/orderContent.vue')
const OrderList=()=>import('@/views/order/list/orderList.vue')

Vue.use(VueRouter);

const routes=[
    {
        path:'/',
        component:Layout,
        children:[
            {
                path:'/',
                name:'home',
                component:Home
            },
            {
                path:'/product',
                name:'product',
                component:Product,
                children:[
                    {
                        path:'list', //访问路径：/product/list
                        name:'list',
                        component:List
                    },
                    {
                        path:'category', //访问路径：/product/category
                        name:'categoty',
                        component:Category
                    }
                ]
            },
            {
                path:'/user',
                name:'user',
                component:User,
                children:[
                    {
                        path:'list', //访问路径：/user/list
                        name:'list',
                        component:UserList
                    }
                ]
            },
            {
                path:'/order',
                name:'order',
                component:Order,
                children:[
                    {
                        path:'list', //访问路径：/user/list
                        name:'list',
                        component:OrderList
                    }
                ]
            }
        ]
    },{
        path:'/login',
        name:'login',
        component:Login
    }
]

const router = new VueRouter({
    mode: 'history',
    base:process.env.BASE_URL,
    routes
});

export default router
